package org.jsbd.boss.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IMiguVideoConfigDao;
import org.jsbd.boss.dao.IMiguVideoDaylimitDAO;
import org.jsbd.boss.domian.MiguMusicConfigBean;
import org.jsbd.boss.domian.MiguVideoConfigBean;
import org.jsbd.boss.domian.MiguVideoDaylimitBean;
import org.jsbd.boss.domian.MiguVideoDaylimitVO;
import org.jsbd.boss.service.IMiguVideoDaylimitService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("miguVideoDaylimitService")
public class MiguVideoDaylimitServiceImpl implements IMiguVideoDaylimitService {
	
	@Resource
	private IMiguVideoDaylimitDAO miguVideoDaylimitDAO;
	@Resource
	private IMiguVideoConfigDao miguVideoConfigDao;
	
	/**
	 * 获取所有数据
	 */
	@Override
	public Map<String, Object> findDataWithPage(DataGridModel page, MiguVideoDaylimitVO mmdVO) {
		return miguVideoDaylimitDAO.findDataWithPage(page, mmdVO);
	}

	/**
	 * 新增
	 */
	@Override
	public void save(MiguVideoDaylimitBean mmdBean) {
		miguVideoDaylimitDAO.insert(mmdBean);
	}

	/**
	 * 查询单个实例
	 */
	@Override
	public MiguVideoDaylimitBean findDaylimit(Integer id) {
		return miguVideoDaylimitDAO.selectOne(id);
	}

	/**
	 * 修改
	 */
	@Override
	public void modifyDaylimit(MiguVideoDaylimitBean mmdBean) {
		miguVideoDaylimitDAO.updateDAO(mmdBean);
	}

	/**
	 * 删除
	 */
	@Override
	public void delete(Integer id) {
		miguVideoDaylimitDAO.delete(id);
	}

	/**
	 * 获取增量数据
	 */
	@Override
	public List<MiguVideoDaylimitBean> findDeltaData(int offset) {
		return miguVideoDaylimitDAO.selectDeltaData(offset);
	}
	
	/**
	 * 更新daylimit
	 */
	@Override
	@Transactional("transactionManagerCrack")
	public void updateDaylimit(List<MiguVideoConfigBean> configs, List<MiguVideoDaylimitBean> mmdBeans) {
		miguVideoConfigDao.updateDaylimit(configs);
		miguVideoDaylimitDAO.updateIsExecute(mmdBeans);
	}


	/**
	 * 验证是否存在mark
	 */
	@Override
	public MiguVideoConfigBean hasName(String name) {
		return miguVideoConfigDao.getByName(name);
	}

	@Override
	public boolean isRepeat(String mark) {
		MiguVideoDaylimitBean mmdBean = miguVideoDaylimitDAO.getByMark(mark);
		if (null == mmdBean) {
			return false;
		}
		return true;
	}

}
